//
//  LSFirstCell.m
//  听说弱点强化训练
//
//  Created by 盛超 on 2018/8/22.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "LSFirstCell.h"

@interface LSFirstCell ()

@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UIImageView *lineImageView;
@property (nonatomic,strong) UIButton *btn;

@end

@implementation LSFirstCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        UIButton *btn = [[UIButton alloc] init];
        self.btn = btn;
        CGFloat btnWidth = 104*ScalesH;
        CGFloat btnHeight = 117*ScalesH;//(kHeight-kNavgationBar-100*ScalesH)/3-20-30*ScalesH-50;
        btn.layer.cornerRadius = btnWidth/2;
        btn.layer.masksToBounds = YES;
      //  btn.backgroundColor = [UIColor redColor];
        [self addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(btnWidth, btnHeight));
            make.top.equalTo(self);
            make.centerX.equalTo(self.mas_centerX);
        }];
        [btn addTarget:self action:@selector(pushAction:) forControlEvents:UIControlEventTouchUpInside];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:16.0f];
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(btn.mas_bottom).offset(-15);
            make.left.right.equalTo(self);
            make.height.mas_equalTo(20);
        }];
        
        self.lineImageView = [[UIImageView alloc] init];
        self.lineImageView.image = [UIImage imageNamed:@"箭头"];
        //self.lineImageView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.lineImageView];
        [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(2);
            make.centerX.equalTo(self.mas_centerX);
            make.bottom.equalTo(self).offset(-10);
            make.width.mas_equalTo(7);
        }];
    }
    
    return self;
}

- (void)setDict:(NSDictionary *)dict {
    _dict = dict;
    NSNumber *indexPathRow = dict[@"IndexPathRow"];
    
    if (indexPathRow.integerValue==0) {
        [self.btn setBackgroundImage:[UIImage imageNamed:@"慢速听力训练"] forState:UIControlStateNormal];
         self.titleLabel.text = @"慢速听力训练";
    } else if (indexPathRow.integerValue==1) {
        [self.btn setBackgroundImage:[UIImage imageNamed:@"慢速听力训练"] forState:UIControlStateNormal];
        self.titleLabel.text = @"中速听力训练";
    } else if (indexPathRow.integerValue==2) {
        [self.btn setBackgroundImage:[UIImage imageNamed:@"慢速听力训练"] forState:UIControlStateNormal];
        self.titleLabel.text = @"快速听力训练";
        self.lineImageView.alpha = 0;
    }
  
    NSNumber *stage = dict[@"Stage"];
    if(indexPathRow.integerValue!=stage.integerValue) {
        
    }
    
}

- (void)pushAction:(UIButton*)sender {
    self.pushBlock();
}

@end
